<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/28
 * Time: 17:08
 */

namespace app\home\controller;



use app\portal\service\PostService;
use cmf\controller\BaseController;
use think\Db;

class NewController extends BaseController
{
    public function index(){
        $post_type  = $this->request->param();

        unset($post_type['page']);
        if ($post_type['post_type']==3){
            $show_type="企业新闻";
        }else{
            $show_type="行业新闻";
        }
        $this->assign('show_type',$show_type);
        $list=Db::name("portal_post")->where($post_type)->where('post_status',1)->order('create_time desc')->paginate(10);
        $this->assign('page', $list->render());
        $new=array();
       if($list){
           foreach ($list as $k=>$v){
               $icon=json_decode($v['more'],true);
               if(strpos($icon['thumbnail'],'http') === false) {
                   $new[$k]['thumbnail']="/public/upload/".$icon['thumbnail'];;
               }else{
                   $new[$k]['thumbnail']=$icon['thumbnail'];
               }
               $new[$k]['post_excerpt']=$v['post_excerpt'];
               $new[$k]['post_title']=$v['post_title'];
               $new[$k]['create_time']=$v['create_time'];
               $new[$k]['id']=$v['id'];
               $new[$k]['post_type']=$v['post_type'];
           }
       }

        $this->assign("new",$new);
       return $this->fetch(":new");
    }

}